home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0" encoding="utf-8" ?>
- <!DOCTYPE stack PUBLIC "-//Apple, Inc.//DTD stack V 2.0//EN" "" >
- <stack>
- <name>in.2</name>
- <id>-1</id>
- <cardCount>7</cardCount>
- <cardID>5256</cardID>
- <listID>4741</listID>
- <cantModify><false /></cantModify>
- <cantDelete><false /></cantDelete>
- <cantAbort><false /></cantAbort>
- <cardSize>
- <width>512</width>
- <height>342</height>
- </cardSize>
- <script>---------------------------------------------------------------------
- -- Groupies 3.0, a utility for grouping objects, by Sioux Lacy
- -- This stack is public domain. Happy grouping!
- --
- -- 04 May 1988 v2.1 revised for HyperCard version 1.2
- -- 07 May 1988 v2.2 added ability to copy the text in fields
- -- 01 June 1988 v2.3 revised to allow selection by dragging a rect
- -- 02 June 1988 v2.4 revised for use with functionKeys f5 thru f10
- -- 22 July 1988 v3.0 added equal space feature, revised presentation
- --
- -- Many thanks to Bill Atkinson for his help and encouragement
- ---------------------------------------------------------------------
-
- -- You don't need to copy this first handler to your Home stack
- -- unless you have an extended keyboard (with function keys).
-
- -- On an extended keyboard, this handler can be used to do Groupies
- -- messages by typing the function keys. It uses keys F5 thru F11.
-
- on functionKey whichKey
- global objectList
- if whichKey < 5 or whichKey > 11 then pass functionKey
- if whichKey is 5 then Group
- else if whichKey is 6 then Move
- else if whichKey is 7 then Copy
- else if whichKey is 8 then Paste
- else if whichKey is 9 then Erase
- else if whichKey is 10 then Align
- else if whichKey is 11 then Adjust
- end functionKey
-
- ---------------------------------------------------------------------
- -- GROUPIES HANDLERS START HERE
- ---------------------------------------------------------------------
-
- -- Message: Group
- -- This will let the user designate a number of objects to be grouped
- -- either by clicking on them, or showing a surrounding rectangle
-
- on Group
- global objectList, whereTheGroupIs
- put "Objects" into selectMethod -- default method
- if the optionKey is down then
- put Choice("Group objects by selecting:", "Objects", "Area") ¬
- into selectMethod
- end if
- if selectMethod is "Objects" then
- Confirm "Click buttons or fields, then press command."
- put empty into objectList
- put empty into whereTheGroupIs
- repeat until the commandKey is down
- set cursor to arrow
- if the mouseClick then
- set cursor to watch
- put HitTest(the clickLoc) into hitWhat
- if hitWhat is not empty and hitWhat is not in objectList
- then put hitWhat & "," after objectList
- else beep -- invalid hit or nothing hit
- end if
- end repeat
- else -- selectMethod is "Area"
- Confirm "Use 2 clicks to show opposite corners of area."
- put empty into objectList
- put empty into whereTheGroupIs
- set cursor to cross
- wait until the mouseClick
- put the clickLoc into selectRect
- DrawMarker selectRect
- wait until the mouseClick
- put "," & the clickLoc after selectRect
- DrawMarker the clickLoc
- set cursor to watch
- EraseMarkers
- WithinRect selectRect
- end if
- delete last char of objectList -- get rid of trailing comma
- choose browse tool
- end Group
-
- -- Message: Move
- -- This will reposition (on the current card) all the
- -- grouped objects.
- -- They will follow the mouse location.
-
- on Move
- global objectList
- CheckGroup
- Confirm "Click and drag the group with mouse down."
- set cursor to arrow
- wait until the mouse is down
- put the mouseLoc into thisLoc
- repeat while the mouse is down
- put thisLoc into lastLoc
- put the mouseLoc into thisLoc
- if thisLoc is not lastLoc then
- put item 1 of thisLoc - item 1 of lastLoc into deltaX
- put item 2 of thisLoc - item 2 of lastLoc into deltaY
- lock screen
- repeat with i = 1 to the number of items in objectList
- put item i of objectList into object
- get location of object
- add deltaX to item 1 of it
- add deltaY to item 2 of it
- set location of object to it
- end repeat
- unlock screen
- end if
- end repeat
- end Move
-
- -- Message: Copy
- -- This will remember, in a global variable, the current card. Then,
- -- when the user 'pastes', the objects will be copied from that card.
-
- on Copy
- global whereTheGroupIs, savedUserLevel
- CheckGroup
- put the userLevel into savedUserLevel
- set the userLevel to 5 -- will be restored after 'Paste'
- Confirm "Go wherever you wish and 'Paste'."
- put the long id of this card into WhereTheGroupIs
- end Copy
-
- -- Message: Paste
- -- This will paste all the objects in the group into the current card /
- -- background. It must be preceded by 'Copy'.
-
- on Paste
- global objectList, WhereTheGroupIs, savedUserLevel
- CheckGroup
- if WhereTheGroupIs is empty
- then Abort "Please choose 'Copy' before 'Paste'."
- set cursor to watch
- set lockMessages to true
- lock screen
- repeat with i = 1 to the number of items in objectList
- push this card
- go to WhereTheGroupIs
- put item i of objectList into object
- if word 2 of object is "field"
- then put the value of object into copyOfText
- select object
- type "C" with commandKey
- pop card
- set editBkgnd to (word 1 of object = "bkgnd")
- type "V" with commandKey
- if word 2 of object is "field" then
- if word 1 of object is "bkgnd"
- then put copyOfText into bkgnd field (the number of bkgnd fields)
- else put copyOfText into card field (the number of card fields)
- end if
- end repeat
- choose browse tool
- unlock screen
- set the userLevel to savedUserLevel
- Prompt "These new objects are not grouped. The old group is still valid."
- end Paste
-
- -- Message: Erase
- -- This will delete all the objects in the group. They are removed
- -- from the stack, and the operation is not undoable.
-
- on Erase
- global objectList, WhereTheGroupIs
- CheckGroup
- Confirm "Deleting group is not undoable. Are you sure?"
- repeat with i = the number of items in objectList down to 1
- select item i of objectList
- type "X" with commandKey
- end repeat
- put empty into objectList
- put empty into WhereTheGroupIs
- choose browse tool
- end Erase
-
- -- Message: Align
- -- This will line up the objects flush left, right, top or bottom,
- -- depending on the user's wishes.
-
- on Align
- global objectList
- CheckGroup
- put Choice("Adjust members by moving them:","Left/Right","Up/Down") ¬
- into axis
- if axis is "Up/Down"
- then answer "Align objects at:" with "Top" or "Bottom" or "Center"
- else answer "Align objects at:" with "Left" or "Right" or "Center"
- put it into alignment
- Confirm "Click where you wish them to align."
- set cursor to cross
- wait until the mouseClick
- if alignment is "Center" then
- repeat with i = 1 to the number of items in objectList
- put item i of objectList into object
- get location of object
- if axis is "Up/Down"
- then put the clickV into item 2 of it
- else put the clickH into item 1 of it
- set location of object to it
- end repeat
- else
- repeat with i = 1 to the number of items in objectList
- put item i of objectList into object
- if axis is "Up/Down" then
- if alignment is "Top"
- then set top of object to the clickV
- else set bottom of object to the clickV
- else if axis is "Left/Right" then
- if alignment is "Left"
- then set left of object to the clickH
- else set right of object to the clickH
- end if
- end repeat
- end if
- end Align
-
- -- Message: Adjust
- -- This will put an equal amount of 'white' space between consecutive
- -- objects in the group. Note that the objects must be in ascending
- -- order for this to work as expected.
-
- on Adjust
- global objectList
- CheckGroup
- put Choice("Adjust space between objects:","Horizontally","Vertically") ¬
- into adjust
- Confirm "Use 2 clicks to show desired spacing."
- set cursor to cross
- wait until the mouseClick
- put the clickLoc into startLoc
- DrawMarker startLoc
- wait until the mouseClick
- put the clickLoc into endLoc
- DrawMarker endLoc
- SortGroup adjust
- if adjust = "Horizontally" then
- put abs(item 1 of endLoc - item 1 of startLoc) into horizSpace
- put right of item 1 of objectList into lastRight
- repeat with i = 2 to the number of items in objectList
- put item i of objectList into object
- set left of object to lastRight + horizSpace
- put right of object into lastRight
- end repeat
- else -- adjust "Vertically"
- put abs(item 2 of endLoc - item 2 of startLoc) into vertSpace
- put bottom of item 1 of objectList into lastBottom
- repeat with i = 2 to the number of items in objectList
- put item i of objectList into object
- set top of object to lastBottom + vertSpace
- put bottom of object into lastBottom
- end repeat
- end if
- EraseMarkers
- end Adjust
-
- -------------------------------------------------------------
-
- on Abort what
- answer what
- exit to HyperCard
- end Abort
-
- on CheckGroup
- global objectList
- if objectList is empty then Abort "There are no objects in the group."
- end CheckGroup
-
- function Choice prompt, choice1, choice2
- answer prompt with choice1 or choice2 or "Cancel"
- if it is "Cancel" then exit to HyperCard
- return it
- end Choice
-
- on Confirm what
- answer what with "Cancel" or "OK"
- if it is "Cancel" then exit to HyperCard
- end Confirm
-
- on DrawMarker where
- lock screen
- doMenu "New Button"
- put the number of card btns into newBtn
- set icon of card btn newBtn to "Marker Cross"
- set style of card btn newBtn to transparent
- set showName of card btn newBtn to false
- set rect of card btn newBtn to 0,0,20,20
- set loc of card btn newBtn to where
- set name of card btn newBtn to empty
- choose browse tool
- unlock screen
- end DrawMarker
-
- on EraseMarkers
- lock screen
- select card btn (the number of card btns)
- doMenu "Clear Button"
- select card btn (the number of card btns)
- doMenu "Clear Button"
- choose browse tool
- unlock screen
- end EraseMarkers
-
- function HitTest where
- repeat with i = the number of card buttons down to 1
- if where is within rect of card button i then
- if visible of card button i
- then return "card button id " & the id of card button i
- end if
- end repeat
- repeat with i = the number of card fields down to 1
- if where is within rect of card field i then
- if visible of card field i
- then return "card field id " & the id of card field i
- end if
- end repeat
- repeat with i = the number of bkgnd buttons down to 1
- if where is within rect of bkgnd button i then
- if visible of bkgnd button i
- then return "bkgnd button id " & the id of bkgnd button i
- end if
- end repeat
- repeat with i = the number of bkgnd fields down to 1
- if where is within rect of bkgnd field i then
- if visible of bkgnd field i
- then return "bkgnd field id " & the id of bkgnd field i
- end if
- end repeat
- return empty
- end HitTest
-
- on Prompt what
- put what
- put the seconds into startTime
- put the mouseLoc into startLoc
- wait until (the seconds = startTime+10) or (the mouseLoc <>¬ startLoc)
- put empty into message box
- hide message box
- end Prompt
-
- on SortGroup how
- global objectList
- put empty into sortedList
- if how is "Vertically" then put true into verticalSort
- else put false into verticalSort
- repeat with i = 1 to the number of items in objectList
- put false into inserted
- if verticalSort then get top of item i of objectList
- else get left of item i of objectList
- repeat with j = 1 to the number of items in sortedList
- if (verticalSort and (it < top of item j of sortedList)) or ¬
- (not verticalSort and (it < left of item j of sortedList)) then
- put item i of objectList & "," before item j of sortedList
- put true into inserted
- exit repeat
- end if
- end repeat
- if inserted is false then put item i of objectList & "," after ¬
- sortedList
- end repeat
- delete last char of sortedList
- put sortedList into objectList
- end SortGroup
-
- on WithinRect selectRect
- global objectList
- repeat with i = the number of card buttons down to 1
- if the loc of card button i is within selectRect then
- if visible of card button i
- then put "card button id " & the id of card button i ¬
- & "," after objectList
- end if
- end repeat
- repeat with i = the number of card fields down to 1
- if the loc of card field i is within selectRect then
- if visible of card field i
- then put "card field id " & the id of card field i ¬
- & "," after objectList
- end if
- end repeat
- repeat with i = the number of bkgnd buttons down to 1
- if the loc of bkgnd button i is within selectRect then
- if visible of bkgnd button i
- then put "bkgnd button id " & the id of bkgnd button i ¬
- & "," after objectList
- end if
- end repeat
- repeat with i = the number of bkgnd fields down to 1
- if the loc of bkgnd field i is within selectRect then
- if visible of bkgnd field i
- then put "bkgnd field id " & the id of bkgnd field i ¬
- & "," after objectList
- end if
- end repeat
- end WithinRect
-
- -----------------------------